package com.lab.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.lab.dao.UserDao;
import com.lab.domain.User;
import com.lab.service.UserService;

@Service("userService")
public class UserServiceImpl implements UserService {
	@Resource
	private UserDao userDao;

	@Override
	public int add(User user) {
		return userDao.add(user);
	}

	@Override
	public int update(User user) {
		return userDao.update(user);
	}

	@Override
	public int delete(String id) {
		return userDao.delete(id);
	}

	@Override
	public List<User> find(Map<String, String> map) {
		return userDao.find(map);
	}

	@Override
	public User login(String id, String password) {
		User user = userDao.findById(id);
		if (null == user)
			return null;
		if (password.equals(user.getPassword())) {
			return user;
		}
		return null;
	}

	@Override
	public User findById(String id) {
		return userDao.findById(id);
	}

}
